/*
package com.geping.etl.common.service.kettle.impl;

import com.geping.etl.common.dto.KettleRunResultDto;
import com.geping.etl.common.service.kettle.RunPathService;
import com.geping.etl.common.service.kettle.RunPathServiceDispatcher;
import lombok.extern.slf4j.Slf4j;
import org.pentaho.di.core.KettleEnvironment;
import org.pentaho.di.job.Job;
import org.pentaho.di.job.JobMeta;
import org.springframework.stereotype.Service;

@Service
@Slf4j
public class KjbRunPathServiceImpl extends RunPathServiceDispatcher implements RunPathService {


    @Override
    public KettleRunResultDto runPath(String pathname) {
        try {
            KettleEnvironment.init();
            JobMeta jobMeta = new JobMeta(pathname, null);
            Job job = new Job(null, jobMeta);
            // 向Job 脚本传递参数，脚本中获取参数值：${参数名}
            // job.setVariable(paraname, paravalue);
            job.start();
            job.waitUntilFinished();
            log.info("result:{}",job.getResult().getResult());
            if (job.getErrors() > 0) {
                log.error("执行跑批失败");
                return KettleRunResultDto.error("执行跑批失败!");
            }else{
                log.error("执行跑批成功");
            }
        } catch (Exception e) {
           log.error("执行kjb发生错误-->",e);
            return KettleRunResultDto.error("执行kjb发生错误!");
        }
        return KettleRunResultDto.success("执行跑批成功!");
    }

    @Override
    public boolean canRun(String pathname) {
        return pathname.endsWith(".kjb");
    }
}*/
